// pages/visa/visa_successpage/visa_successpage.js
Page({

    /**
     * 页面的初始数据
     */
    data: {
        visa_state:false,
        paid:false,
        companyinfos:{},
        status:'',
        deal:'',
        cookie:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        this.setData({
            visa_state:wx.getStorageSync('visa_state')?wx.getStorageSync('visa_state'):false,
            paid:wx.getStorageSync('paid')?wx.getStorageSync('paid'):false
        })
        console.log(this.data.paid,'p')
        this.getInitData()
        const loginInfo=wx.getStorageSync('loginInfo')
        if(loginInfo){
            this.setData({
                cookie:true
            })
        }
    },
    getInitData(){
        this.setData({
            status:'未申领',
            deal:'去申领'
        })
        getApp().network.GET({
            url:'/new/user/elec/info',
            success:res=>{
                let {data}=res.data
                if(res.data.code==0){
                    this.setData({
                        companyinfos:data
                    })
                    const companyinfos=JSON.stringify(this.data.companyinfos)
                    if(data.apply_status==0){
                        this.setData({
                            status:'未申领',
                            deal:'去申请'
                        })
                    }
                    if(data.apply_status==1){
                        this.setData({
                            paid:true
                        })
                    }
                    if(data.apply_status==2||data.apply_status==3){
                        this.setData({
                            deal:'去付费',
                            status:''                        
                         })
                     }  
                }
            }
        })
    },
    gotoDeal(){
        const companyinfos=JSON.stringify(this.data.companyinfos)
        if(this.data.companyinfos.apply_status==0){
            wx.navigateTo({
                url: '../visa_get/visa_get?companyinfos='+companyinfos,
            })
        }
        if(this.data.companyinfos.apply_status==2){
            wx.navigateTo({
                url: '../payment/payment?id=2&companyinfos='+companyinfos,
            })
        }
        if(this.data.companyinfos.apply_status==3){
            wx.navigateTo({
                url: '../payment/payment?id=3&companyinfos='+companyinfos,
            })
            
        }
    },
  
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
    
})